import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ConfigModule } from './cus-modules/config/config.module';
import { AttachAccessToken } from './middleware/AttachAccessToken';
import { TmpMiddleware } from './middleware/tmp.middle';
import { WxEventMessage } from './service/wx-event-message.service';

@Module({
  imports: [ConfigModule.register({ folder: './config' })],
  controllers: [AppController],
  providers: [AppService, WxEventMessage],
})
export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer
      .apply(AttachAccessToken)
      .forRoutes('/api/*')
      .apply(TmpMiddleware)
      .forRoutes('*');
  }
}
